home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93b.txt / 000105_icon-group-sender _Wed May 19 18:19:10 1993.msg < prev    next >
Internet Message Format  |  1993-06-16  |  2KB

  1. Received: from owl.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Thu, 20 May 1993 08:00:43 MST
  2. Received: by owl.cs.arizona.edu; Thu, 20 May 1993 08:00:41 MST
  3. Date: 19 May 93 18:19:10 GMT
  4. From: agate!howland.reston.ans.net!ux1.cso.uiuc.edu!uchinews!ellis!goer@ucbvax.Berkeley.EDU  (Richard L. Goerwitz)
  5. Organization: University of Chicago
  6. Subject: Re: A bug? Or a feature?
  7. Message-Id: <1993May19.181910.14699@midway.uchicago.edu>
  8. References: <12743@sun13.scri.fsu.edu>
  9. Sender: icon-group-request@cs.arizona.edu
  10. To: icon-group@cs.arizona.edu
  11. Status: R
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13.  
  14. John Nall writes that the Icon manual says:
  15. >
  16. >    X1 op:= X2
  17. >      "performs the operation X1 op X2 and assigns the result to X1
  18. >
  19. >   ...To wit: it actually:
  20. >
  21. >    "performs the operation X1 op (X2) and assigns the result to X1"
  22.  
  23. I see what you mean.  The problem is with how you define X1 and X2.
  24.  
  25. Here's the scoup:  Think of X1 and X2 as expression 1 and expression 2.
  26. How do we group expressions?  By operator precedence and newlines.  What
  27. is the precedence of <:=, for example?  It is the same as any assignment
  28. operator's.  What is the precedence of >, say?  It is the same as that
  29. of any comparison operator.
  30.  
  31. Now we can answer the question of how the following expression groups:
  32.  
  33. >        i <:= j > k
  34.  
  35. Since comparison has a higher precedence than assignment, we group (j > k)
  36. as one expression.  Hence the correct grouping of the entire assignment
  37. expression is:
  38.  
  39.     i <:= (j > k)
  40.  
  41. Ergo i is expression 1, and (j > k) is expression 2.  The augmented assign-
  42. ment operator adds the result of expression 2 to expression 1, and assigns
  43. the result to expression 1 (if, in fact, expression 1 produces a variable).
  44.  
  45. So the Icon book is, in fact, correct, using its own definitions.  op:= is
  46. not a macro; it is a regular assignment operator.  You just have to figure
  47. out how the surrounding expressions group.
  48.  
  49. Note:
  50.  
  51. What your comments indicate is that the Icon book's explanation, while cor-
  52. rect, may not be intuitive to everyone.  Good question.
  53.  
  54. -- 
  55.  
  56.    -Richard L. Goerwitz              goer%midway@uchicago.bitnet
  57.    goer@midway.uchicago.edu          rutgers!oddjob!ellis!goer
  58.